<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>实勘</title>
    <link rel="stylesheet" href="../../css/weui.css">
    <link rel="stylesheet" href="../../css/amazeui.css">
    <link rel="stylesheet" type="text/css" href="../../css/jquery.datetimepicker.css" />
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />

</head>
<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    body,
    html {
        width: 100%;
        background: #f0f0f0;
    }

    header {
        text-align: center;
        height: 44px;
        line-height: 44px;
        position: relative;
    }

    .button {
        width: 80%;
        margin: 30px auto;
        display: block;
        outline: none;
    }

    .am-input-group-label {
        background: #fff;
        border: none;
        font-size: 14px;
    }

    .am-form-field {
        border: none;
        text-align: right;
        outline: none;
        padding-right: 16px;
    }

    .am-input-group {
        position: relative
    }

    .weui-picker__action {
        color: #0e90d2;
    }

    .am-form-field {
        color: #000;
    }

    .xinxiTitle {
        padding: 0px 12px;
        margin-top: 5px;
        height: 38px;
        line-height: 38px;
        background: #fff;
    }

    .xinxibox {
        background: #FFF;
        padding: 10px;
    }
    .xinxiTITLE_2 {
        padding: 0 12px;
        height: 38px;
        line-height: 38px;
        background: transparent;
        margin-bottom: 10px;
        color: #777;
    }

    .am-checkbox-inline+.am-checkbox-inline,
    .am-radio-inline+.am-radio-inline {
        margin: 0
    }
    .am-btn-primary{
        border-radius: 8px ;
    }
    .am-btn{
    font-size: 14px; 
    color: #fff;
    padding: 10px;
    outline: none;
    background-color:rgba(0,0,0,0);
    border:none;
    }
    #bianhao{
        font-size: 12px;
    }
    #datetimepicker{
        border: none;
    }
    .button {
            width: 90%;
            margin: 30px auto;
            display: block;
            outline: none;
            background: #1197ff;
            border-radius: 5px;
            height: 40px;
        }
        .list_box{
            border-bottom: 1px solid #dadada99;
        }
        .xinxibox>.list_box:last-child{
            border: none;
        }
</style>

<body>
    <!-- <div class="shenhe" style="
        width: 60px;
    height: 60px;
    position: fixed;
    right: 10px;
    bottom: 10px;
    background: #1197ff;
    font-size: 13px;
    border-radius: 100%;
    text-align: center;
    line-height: 60px;
    color: #fff;
    z-index: 9999;
    border: 1px solid #1284dc;
    ">
        提交审核
    </div> -->
    <div data-am-widget="tabs" style="margin:0;background: #FFF;" class="box am-tabs am-tabs-default">
        <ul style="background: #FFF;" class="am-tabs-nav am-cf">
            <li onclick="window.location.href='./dingdanxinxi.html?id='+GetQueryString('id')+'&SerialNumber='+GetQueryString('SerialNumber')"
                class="">
                <a href="javascript:;">订单详情</a>
            </li>
            <li onclick="window.location.href='./diyaxinxi.html?id='+GetQueryString('id')+'&SerialNumber='+GetQueryString('SerialNumber')"
                class="">
                <a href="javascript:;">抵押信息</a>
            </li>
            <li onclick="window.location.href='./daikuanxinxi.html?id='+GetQueryString('id')+'&SerialNumber='+GetQueryString('SerialNumber')"
                class="am-active">
                <a href="javascript:;">贷款信息</a>
            </li>
            <li onclick="window.location.href='./diaochazongshu.html?id='+GetQueryString('id')+'&SerialNumber='+GetQueryString('SerialNumber')"
                class="">
                <a href="javascript:;">调查综述</a>
            </li>
            <li onclick="window.location.href='./zhaopian.html?id='+GetQueryString('id')+'&SerialNumber='+GetQueryString('SerialNumber')"
                class="">
                <a href="javascript:;">照片</a>
            </li>
        </ul>
    </div>
    <div class="xinxiTitle" id="bianhao">
        订单编号：HD201802032268
    </div>
    <div class="xinxiTITLE_2">
        抵押物目前状况
    </div>
    <div class="xinxibox">
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">是否有抵押：</span>
                <div style="text-align: left" class="am-form-group am-form-field">
                    <label class="am-radio-inline">
                        <input checked type="radio" value="1" class="HaveMortgage" name="HaveMortgage">否
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" class="HaveMortgage" name="HaveMortgage"> 是
                    </label>
                </div>
            </div>
        </div>
        <div class="list_box HaveMortgagebox">
            <div class="am-input-group">
                <span class="am-input-group-label">抵押形式：</span>
                <input type="text" class="am-form-field input" name="MortgageForm" placeholder="请输入">
            </div>
        </div>
        <div class="list_box HaveMortgagebox">
            <div class="am-input-group">
                <span class="am-input-group-label">机构名称：</span>
                <input type="text" class="am-form-field input" name="InstitutionName" placeholder="请输入">
            </div>
        </div>
        <div class="list_box HaveMortgagebox">
            <div class="am-input-group">
                <span class="am-input-group-label">贷款金额：</span>
                <input type="text" class="am-form-field input" name="LoanMoney" placeholder="请输入">
            </div>
        </div>
        <div class="list_box HaveMortgagebox">
            <div class="am-input-group">
                <span class="am-input-group-label">贷款期限：</span>
                <input type="text" class="am-form-field input" name="TimeLimit" placeholder="请输入">
            </div>
        </div>
        <div class="list_box HaveMortgagebox">
            <div class="am-input-group">
                <span class="am-input-group-label">贷款余额：</span>
                <input type="text" class="am-form-field input" name="LoanBalance" placeholder="请输入">
            </div>
        </div>
    </div>
    <div class="xinxiTITLE_2">
        用款状况
    </div>
    <div class="xinxibox">
        <div style="padding-left:14px" class="list_box">
            <div class="am-input-group">
                <div>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="0"> 一抵：
                    </label>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="1"> 新增
                    </label>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="2"> 上二解一
                    </label>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="3"> 老客户
                    </label>
                </div>
                <div>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" class="erdicheckbox" value="4"> 二抵：
                    </label>
                    <!-- <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="5"> 一抵机构
                    </label>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="6"> 一抵金额
                    </label>
                    <label class="am-checkbox-inline ">
                        <input type="checkbox" name="SequenceMortgage" value="7"> 一抵剩余本金
                    </label> -->
                </div>
            </div>
        </div>
        <div class="erdi">
            <div class="list_box">
                <div class="am-input-group">
                    <span class="am-input-group-label">一抵机构：</span>
                    <input type="text" class="am-form-field input" name="YiDiJiGou" placeholder="请输入">
                </div>
            </div>
            <div class="list_box">
                <div class="am-input-group">
                    <span class="am-input-group-label">一抵金额：</span>
                    <input type="text" class="am-form-field input" name="YiDiJinE" placeholder="请输入">
                </div>
            </div>
            <div class="list_box">
                <div class="am-input-group">
                    <span class="am-input-group-label">一抵剩余本金：</span>
                    <input type="text" class="am-form-field input" name="YiDiShengYuBenJin" placeholder="请输入">
                </div>
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">借款人与抵押人是否一致：</span>
                <div style="text-align: left" class="am-form-group am-form-field">
                    <label class="am-radio-inline">
                        <input checked type="radio" value="1" class="AreConsistent" name="AreConsistent">否
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" class="AreConsistent" name="AreConsistent"> 是
                    </label>
                </div>
            </div>
        </div>
        <div class="list_box AreConsistentbox">
            <div class="am-input-group">
                <span class="am-input-group-label">借款人与抵押人是否有关系：</span>
                <div style="text-align: left" class="am-form-group am-form-field">
                    <label class="am-radio-inline">
                        <input checked type="radio" value="1" name="IsRelationship">否
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" name="IsRelationship"> 是
                    </label>
                </div>
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">贷款用途一级：</span>
                <input type="text" class="am-form-field input" name="LoanOneUse" placeholder="请输入">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">贷款用途二级：</span>
                <input type="text" class="am-form-field input" name="LoanTwoUse" placeholder="请输入">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">还款来源一级：</span>
                <input type="text" class="am-form-field input" name="ReimOne" placeholder="请输入">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">还款来源二级：</span>
                <input type="text" class="am-form-field input" name="ReimTwo" placeholder="请输入">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">申请金额：</span>
                <input type="text" class="am-form-field input" name="ApplyAmount" placeholder="请输入">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">申请期限：</span>
                <input type="text" class="am-form-field input" name="ApplyLimit" placeholder="请输入">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">希望放款时间：</span>
                <input class=" am-form-field input time" type="text" name="LoanTime" readonly="readonly" id="datetimepicker"
                    readonly="readonly" name="Birthday" placeholder="请输入日期" onclick="laydate({istime: true,format:'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">是否对家庭隐瞒贷款信息：</span>
                <div style="text-align: left" class="am-form-group am-form-field">
                    <label class="am-radio-inline">
                        <input checked type="radio" value="1" name="HideFamily">否
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" name="HideFamily"> 是
                    </label>
                </div>
            </div>
        </div>

        <div class="list_box">
            <div class="am-input-group">
                <span class="am-input-group-label">家庭是否不支持贷款：</span>
                <div style="text-align: left" class="am-form-group am-form-field">
                    <label class="am-radio-inline">
                        <input checked type="radio" value="1" name="FamilySupport">否
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" name="FamilySupport"> 是
                    </label>
                </div>
            </div>
        </div>
    </div>
    <div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">提示</div>
            <div class="am-modal-bd cont">
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">确定</span>
            </div>
        </div>
    </div>
    <button class="button am-btn am-btn-primary">提交</button>
    <div class="shenhe" style="
    width: 90%;
    margin: 30px auto;
    display: block;
    outline: none;
    background: #1197ff;
    border-radius: 5px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    color: #fff;
">
        提交审核
    </div>
    <script src="../../js/jquery-3.2.1.min.js"></script>
    <script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
    <script src="../../js/amazeui.js"></script>
    <script src="../../js/jquery.datetimepicker.js"></script>
    <style>
        input[readonly="readonly"] {
            background: #fff !important;
        }
    </style>
    <script>
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
        var myDate = new Date();
        $('.time').val(myDate.toLocaleDateString() + " " + myDate.getHours() + ':' + myDate.getMinutes()).css('border', 'none')

        var zhi = localStorage.getItem('zhi')
        var SerialNumber = localStorage.getItem('SerialNumber')
        var http = localStorage.getItem('http')
        var UserId = localStorage.getItem('UserId')
        var Access_token = localStorage.getItem('Access_token')
        var Refresh_token = localStorage.getItem('Refresh_token');
        $('#bianhao').text('订单编号：' + SerialNumber)

        $(function () {
            $.ajax({
                type: 'GET',
                url: http + '/api/prosprct/GetAllOrderMes',
                headers: {
                    "Authorize": Access_token + '|' + Refresh_token
                },
                data: {
                    keyValue: zhi
                },
                async: false,
                success: function (data) {
                    // console.log(JSON.stringify(data));
                    // console.log(Object.keys(data.resultdata));
                    dataarr = Object.keys(data.resultdata)
                    for (var datakeys = 0; datakeys < Object.keys(data.resultdata).length; datakeys++) {
                        var MM = $("input[name=\'" + dataarr[datakeys] + "']")
                        var type = MM.attr('type');
                        console.log(type);
                        if (type == 'text') {
                            if (data.resultdata[dataarr[datakeys]] != 0) {
                                MM.val(data.resultdata[dataarr[datakeys]])
                            }
                        } else if (type == 'radio') {
                            if (data.resultdata[dataarr[datakeys]] == true) {
                                $("input[name=\'" + dataarr[datakeys] + "']").removeAttr('checked');
                                $("input[name=\'" + dataarr[datakeys] + "']input[value='0']").prop('checked', true);
                            } else {
                                $("input[name=\'" + dataarr[datakeys] + "']").removeAttr('checked');
                                $("input[name=\'" + dataarr[datakeys] + "']input[value='1']").prop('checked', true);
                            }
                        } else if (type == 'number') {
                            if (data.resultdata[dataarr[datakeys]] != 0) {
                                MM.val(data.resultdata[dataarr[datakeys]])
                            }
                        } else if (type == 'checkbox') {
                            if (data.resultdata[dataarr[datakeys]] != null) {
                                var duoxuan = data.resultdata[dataarr[datakeys]].split(',');
                                for (var po = 0; po < duoxuan.length; po++) {
                                    $("input[name=\'" + dataarr[datakeys] + "']input[value='" + duoxuan[po] + "']").prop('checked', true);
                                }
                            }
                        } else if (type == 'file') {
                            $("input[name=\'" + dataarr[datakeys] + "']").attr('srcimg', data.resultdata[dataarr[datakeys]]);
                        }
                    }
                },
                error: function (err) {
                    alert('获取数据失败')
                    console.log(JSON.stringify(err));
                }
            })
            time = false
            if ($('.erdicheckbox').prop('checked') == true) {
                $('.erdi').show();
                erdi = true
            } else {
                $('.erdi').hide();
                erdi = false
            }
            $('.erdicheckbox').change(function () {
                if ($('.erdicheckbox').prop('checked') == true) {
                    $('.erdi').show();
                    erdi = true
                } else {
                    $('.erdi').hide();
                    erdi = false
                }
            })
            $('#showDatePicker').on('click', function () {
                weui.datePicker({
                    start: 1990,
                    end: new Date().getFullYear(),
                    onChange: function (result) {
                        console.log(result);
                    },
                    onConfirm: function (result) {
                        console.log(result[0] + '-' + result[1] + '-' + result[2]);
                        $('#showDatePicker').text(result[0] + '-' + result[1] + '-' +
                            result[2])
                        time = true
                    }
                });
            })

            if ($('.HaveMortgage').eq(0).prop('checked') == true) {
                $('.HaveMortgagebox').hide();
                HaveMortgage = false
            } else {
                $('.HaveMortgagebox').show();
                HaveMortgage = true
            }
            $('.HaveMortgage').change(function () {
                if ($('.HaveMortgage').eq(0).prop('checked') == true) {
                    $('.HaveMortgagebox').hide();
                    HaveMortgage = false
                } else {
                    $('.HaveMortgagebox').show();
                    HaveMortgage = true
                }
            })
            if ($('.AreConsistent').eq(1).prop('checked') == true) {
                $('.AreConsistentbox').hide();
                AreConsistent = false
            } else {
                $('.AreConsistentbox').show();
                AreConsistent = true
            }
            $('.AreConsistent').change(function () {
                if ($('.AreConsistent').eq(1).prop('checked') == true) {
                    $('.AreConsistentbox').hide();
                    AreConsistent = false
                } else {
                    $('.AreConsistentbox').show();
                    AreConsistent = true
                }
            })
            $('.button').click(function () {
                // // 限制
                for (var p = 0; p < $('.input').length; p++) {
                    if ($('.input').eq(p)[0].localName == 'input') {
                        if ($('.input').eq(p).val() == '') {
                            var te = $('.input').eq(p).parent().find('span').text()
                            console.log(te)
                            if (HaveMortgage == false && erdi == false) {
                                if (te == '抵押形式：') {

                                } else if (te == '机构名称：') {

                                } else if (te == '贷款金额：') {

                                } else if (te == '贷款期限：') {

                                } else if (te == '贷款余额：') {

                                } else if (te == '一抵机构：') {

                                } else if (te == '一抵金额：') {

                                } else if (te == '一抵剩余本金：') {

                                } else {
                                    $(".cont").text('请输入' + te.replace('：', ''))
                                    $('#my-alert').modal('open')
                                    $('.button').removeAttr('disabled')
                                    return
                                }
                            } else if (HaveMortgage == true && erdi == false) {
                                if (te == '一抵机构：') {

                                } else if (te == '一抵金额：') {

                                } else if (te == '一抵剩余本金：') {

                                } else {
                                    $(".cont").text('请输入' + te.replace('：', ''))
                                    $('#my-alert').modal('open')
                                    $('.button').removeAttr('disabled')
                                    return
                                }
                            } else if (HaveMortgage == false && erdi == true) {
                                if (te == '抵押形式：') {

                                } else if (te == '机构名称：') {

                                } else if (te == '贷款金额：') {

                                } else if (te == '贷款期限：') {

                                } else if (te == '贷款余额：') {

                                }else {
                                    $(".cont").text('请输入' + te.replace('：', ''))
                                    $('#my-alert').modal('open')
                                    $('.button').removeAttr('disabled')
                                    return
                                }
                            } else {
                                $(".cont").text('请输入' + te.replace('：', ''))
                                $('#my-alert').modal('open')
                                $('.button').removeAttr('disabled')
                                return
                            }
                        }
                    } else if ($('.input').eq(p)[0].localName == 'div') {
                        if ($('.input').eq(p).text().length == 205) {
                            var te = $('.input').eq(p).parent().find('span').text()
                            $(".cont").text('请选择' + te.replace('：', ''))
                            $('#my-alert').modal('open')
                            $('.button').removeAttr('disabled')
                            return
                        }
                    }
                }
                // 拼接
                var obj = {};
                for (var i = 0; i < $('.input').length; i++) {
                    var Name = $('.input').eq(i).attr('name');
                    if ($('.input').eq(i)[0].localName == 'input') {
                        obj[Name] = $('.input').eq(i).val()
                    } else {
                        obj[Name] = $('.input').eq(i).text()
                    }
                }

                for (var lpl = 0; lpl < $('input[type="radio"]').length; lpl++) {
                    if ($('input[type="radio"]').eq(lpl).prop('checked') == true) {
                        var lpltext = $('input[type="radio"]').eq(lpl).val()
                        var lplname = $('input[type="radio"]').eq(lpl).attr('name')
                        if (lpltext == '0') {
                            lpltext = true;
                        } else {
                            lpltext = false;
                        }
                        obj[lplname] = lpltext
                    }
                }
                for (var lpl = 0; lpl < $('input[type="checkbox"]').length; lpl++) {
                    var oo = [];
                    var name = $('input[type="checkbox"]').eq(lpl).attr('name')
                    $('input[name="' + name + '"]:checked').each(function () {
                        oo.push($(this).val());
                    });

                    var ppppo = oo.join(',');
                    obj[name] = ppppo
                }
                if (obj.SequenceMortgage == '') {
                    $(".cont").text(' 一抵或者 二抵请选择至少一项')
                    $('#my-alert').modal('open')
                    return
                }
                console.log(JSON.stringify(obj));
                $.ajax({
                    type: 'POST',
                    url: http + '/api/prosprct/SaveLoanInformation?keyWord=' + zhi,
                    headers: {
                        "Authorize": Access_token + '|' + Refresh_token,
                        "MemberId": UserId
                    },
                    async: false,
                    data: obj,
                    dataType: "json",
                    success: function (data) {
                        console.log(JSON.stringify(data))
                        $(".cont").text(data.message)
                        $('#my-alert').modal('open')
                    },
                    error: function (err) {
                        console.log(JSON.stringify(err))
                    }
                })

            })
        })

        $('.shenhe').on('click', function () {
            $.ajax({
                type: 'POST',
                url: http + '/api/prosprct/SaveExploitation?keyWord=' + zhi,
                headers: {
                    "Authorize": Access_token + '|' + Refresh_token
                },
                data: {},
                success: function (data) {
                    console.log(JSON.stringify(data));
                    alert(data.message)
                    if (data.type == 1) {
                        window.location.replace("../dingfan.html")
                    }
                },
                error: function (err) {
                    console.log(JSON.stringify(err));
                }
            })
        })
    </script>
</body>

</html>